package com.haoshuang.zhouzhoubang.ui.dialog

import android.content.Context
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.DialogBusinessLicenseBinding
import com.lxj.xpopup.core.CenterPopupView
import com.mufeng.libs.utils.SpannableStringUtils
import com.mufeng.libs.utils.view.click

/**
 * 提示上传营业执照
 */
class BusinessLicenseDialog(context: Context, private val onUpload: () -> Unit): CenterPopupView(context) {

    private lateinit var binding: DialogBusinessLicenseBinding

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_business_license
    }

    override fun onCreate() {
        super.onCreate()
        binding = DialogBusinessLicenseBinding.bind(popupImplView)

        val tip = "门店已超过规定时间未上产营业执照，\n已被标记沉默门店推单接单将受到影响"
        val span = SpannableStringUtils(context, tip)
            .first("推单接单")
            .textColor(R.color.c_ff0000)

        binding.tvContent.text = span

        binding.ivClose.click { dismiss() }
        binding.tvUpload.click {
            dismiss()
            onUpload()
        }
    }
}